import 'package:baselib/utils/image_util.dart';
import 'package:baselib/widgets/comm_app_bar.dart';
import 'package:baselib/widgets/inkwell_button.dart';
import 'package:baselib/widgets/nosize_app_bar.dart';
import 'package:baselib/widgets/simple_button.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:framelib/utils/color_util.dart';
import 'package:framelib/utils/drawable_util.dart';
import 'package:framelib/utils/px_util.dart';
import 'package:framelib/utils/string_util.dart';
import 'package:framelib/widgets/comm_widget_manager.dart';
import 'package:framelib/widgets/main_gradient_button.dart';
import 'package:framelib/widgets/page_widget.dart';
import 'package:get/get.dart';
import 'package:module_business/module_comm/viewmodel/login_view_model.dart';
/**
 * 登录主页
 */
class LoginPage extends GetWidget<LoginViewModel> {
  @override
  Widget build(BuildContext context) {
    return PageWidget.build(
        builder: (LoginViewModel model){
          return PageWidget.PageScaffoldWidget(
            isShowBg: true,
            // appBar: CommAppBar(
            //   // isBarStatusWhite: false,
            //   leading: SizedBox(width: PxUtil.instance.px_0,),
            //   backgroundColor: ColorUtil.instance.color_transparent,
            //   // elevation: PxUtil.instance.px_0,
            // ),

            body: SingleChildScrollView(
              child:Container(
                // color: ColorUtil.instance.color_white,
                width: PxUtil.instance.screenWidth,
                height: PxUtil.instance.screenHeight-PxUtil.instance.statusBarHeight
                -PxUtil.instance.appBarHeight
                ,
                padding: EdgeInsets.only(
                  left: PxUtil.instance.px_26,
                  right: PxUtil.instance.px_26,
                ),
                child: Column(
                  crossAxisAlignment: CrossAxisAlignment.start,
                  children: [
                    //logo
                    SizedBox(
                      height: PxUtil.instance.screenHeight/4,
                    ),
                    Expanded(child: Row(
                      mainAxisAlignment: MainAxisAlignment.center,
                      crossAxisAlignment: CrossAxisAlignment.start,
                      children: [
                        Container(
                            width: PxUtil.instance.px_120,
                            height: PxUtil.instance.px_120,
                            alignment: Alignment.center,
                            decoration: BoxDecoration(
                                gradient: LinearGradient(
                                    begin: Alignment.topCenter,
                                    end: Alignment.bottomCenter,
                                    colors: [
                                      ColorUtil.instance.color_AE2CF1,
                                      ColorUtil.instance.color_7776FF,
                                    ]),
                                borderRadius: BorderRadius.circular(PxUtil.instance.px_60)
                            ),
                            child: ImagesUtil.loadAssetImage(
                                DrawableUtil.instance.icon_login,
                                height: PxUtil.instance.px_24,
                                fit: BoxFit.fitHeight
                            )
                        )
                      ],
                    )),
                    //Emal Sign in
                    MainGradientButton(
                      onPressed: ()=>model.toEmailSignIn(),
                      isImg: true,
                      imgPath: DrawableUtil.instance.icon_login_email_sign_in,
                      imgWidth: PxUtil.instance.px_116,
                    ),
                    SizedBox(height: PxUtil.instance.screenHeight/8+PxUtil.instance.px_20,),
                    //Apple
                    // MainGradientButton(
                    //   onPressed: ()=>model.toEmailSignIn(),
                    //   isImg: true,
                    //   imgPath: DrawableUtil.instance.icon_login_apple,
                    //   imgWidth: PxUtil.instance.px_50,
                    // ),
                    //点击用户协议
                    Row(
                      crossAxisAlignment: CrossAxisAlignment.center,
                      mainAxisAlignment: MainAxisAlignment.center,
                      children: [
                        InkWellButton(
                          onPressed: ()=>model?.selectAgreement(),
                          child: Container(
                            margin: EdgeInsets.only(
                              // bottom: PxUtils.px_2
                            ),
                            child: Obx(()=>ImagesUtil.loadAssetImage(
                                model?.isAgreementSelected.value?
                                DrawableUtil.instance.icon_selected:DrawableUtil.instance.icon_unselected,
                                width: PxUtil.instance.px_20
                            )),
                          ),
                        ),
                        SizedBox(
                          width: PxUtil.instance.px_15,
                        ),
                        InkWellButton(
                          onPressed: ()=>model.toTermsOfService(),
                          child: Text(
                            '${StringUtil.instance.Terms_of_Service}',
                            style: TextStyle(
                                fontSize: PxUtil.instance.px_12,
                                color: ColorUtil.instance.color_white
                            ),
                          ),
                        ),
                        Text(
                          ' ${StringUtil.instance.he} ',
                          style: TextStyle(
                              fontSize: PxUtil.instance.px_12,
                              color: ColorUtil.instance.color_8927ED
                          ),
                        ),
                        InkWellButton(
                          onPressed: ()=>model.toPrivacyPolicy(),
                          child: Text(
                            '${StringUtil.instance.Privacy_Policy}',
                            style: TextStyle(
                                fontSize: PxUtil.instance.px_12,
                                color: ColorUtil.instance.color_white
                            ),
                          ),
                        ),
                      ],
                    ),
                    SizedBox(
                      height: PxUtil.instance.px_15,
                    ),
                  ],
                ),
              ),
            ),
          );
        }
    );
  }

}
